namespace SuppKids.Migrator.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class ProductConsumptionDaily : DbMigration
    {
        public override void Up()
        {
            DropForeignKey("dbo.Ingredients", "Dish_Id", "dbo.Dishes");
            DropForeignKey("dbo.Ingredients", "Product_Id", "dbo.Products");
            DropIndex("dbo.Ingredients", new[] { "Dish_Id" });
            DropIndex("dbo.Ingredients", new[] { "Product_Id" });
            AddColumn("dbo.ProductConsumptionValues", "DailyMenu_Id", c => c.Int(nullable: true));
            CreateIndex("dbo.ProductConsumptionValues", "DailyMenu_Id");
            CreateIndex("dbo.Ingredients", "Dish_Id");
            CreateIndex("dbo.Ingredients", "Product_Id");
            AddForeignKey("dbo.ProductConsumptionValues", "DailyMenu_Id", "dbo.DailyMenus", "Id", cascadeDelete: true);
            AddForeignKey("dbo.Ingredients", "Dish_Id", "dbo.Dishes", "Id");
            AddForeignKey("dbo.Ingredients", "Product_Id", "dbo.Products", "Id");
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.Ingredients", "Product_Id", "dbo.Products");
            DropForeignKey("dbo.Ingredients", "Dish_Id", "dbo.Dishes");
            DropForeignKey("dbo.ProductConsumptionValues", "DailyMenu_Id", "dbo.DailyMenus");
            DropIndex("dbo.Ingredients", new[] { "Product_Id" });
            DropIndex("dbo.Ingredients", new[] { "Dish_Id" });
            DropIndex("dbo.ProductConsumptionValues", new[] { "DailyMenu_Id" });
            DropColumn("dbo.ProductConsumptionValues", "DailyMenu_Id");
            CreateIndex("dbo.Ingredients", "Product_Id");
            CreateIndex("dbo.Ingredients", "Dish_Id");
            AddForeignKey("dbo.Ingredients", "Product_Id", "dbo.Products", "Id", cascadeDelete: true);
            AddForeignKey("dbo.Ingredients", "Dish_Id", "dbo.Dishes", "Id", cascadeDelete: true);
        }
    }
}
